<script>
import { lang } from '@/locale'
export default {
  name: 'DynTranSelect',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    selectItem: {
      type: Array,
      default: () => ([])
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handlerSelect(value) {
      this.$emit('change', value)
      // 执行事件对象
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      <el-select value={this.value} on-change={this.handlerSelect.bind(this)}
        placeholder={ lang === 'zh-CN' ? '请输入' + `${this.item.label}`
          : 'Please input ' + `${this.item.label}`
        }
      >
        {this.selectItem.map(item => {
          return (
            <el-option
              key={item.id}
              label={this.$t(item.name)}
              value={item.id}>
            </el-option>
          )
        })}
      </el-select>
    )
  }
}
</script>

<style scoped lang="scss"></style>
